/**
 * @author 小泽玛丽罗
 * 
 */
// 对Date的扩展，将 Date 转化为指定格式的String 
// 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符， 
// 年(y)可以用 1-4 个占位符，毫秒(S)只能用 1 个占位符(是 1-3 位的数字) 
// 例子： 
// (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423 
// (new Date()).Format("yyyy-M-d h:m:s.S")      ==> 2006-7-2 8:9:4.18 
Date.prototype.Format = function(fmt) 
{ //author: meizz 
  var o = { 
    "M+" : this.getMonth()+1,                 //月份 
    "d+" : this.getDate(),                    //日 
    "h+" : this.getHours(),                   //小时 
    "m+" : this.getMinutes(),                 //分 
    "s+" : this.getSeconds(),                 //秒 
    "q+" : Math.floor((this.getMonth()+3)/3), //季度 
    "S"  : this.getMilliseconds()             //毫秒 
  }; 
  if(/(y+)/.test(fmt)) 
    fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length)); 
  for(var k in o) 
    if(new RegExp("("+ k +")").test(fmt)) 
  fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length))); 
  return fmt; 
};
String.prototype.replaceAll = function (AFindText,ARepText){
	 raRegExp = new RegExp(AFindText,"g");
	 return this.replace(raRegExp,ARepText);};
String.prototype.endWith=function(s){
	if(s==null||s==""||this.length==0||s.length>this.length)
	return false;
	if(this.substring(this.length-s.length)==s)
	return true;
	else
	return false;
	return true;
	};

	String.prototype.startWith=function(s){
	if(s==null||s==""||this.length==0||s.length>this.length)
	return false;
	if(this.substr(0,s.length)==s)
	return true;
	else
	return false;
	return true;
	};
	/**
	 * 文件的类型，表示文件在文件夹还是在网盘下
	 */
	var TYPE_directory=1;
	var TYPE_disk=2;
	var project={
			getPicClass:function(fileName){
				var type=fileName.substring(fileName.lastIndexOf("."),fileName.length);
				switch (type) {
				case "doc":
					return "file_word_ico_d32";
					break;
				case "xls":
					return "file_excel_ico";
					break;
				case "jpg":
					return "file_photo_ico_d32";
					break;
				case "png":
					return "file_photo_ico_d32";
					break;
				case "pdf":
					return "file_pdf_ico_d32";
					break;
				case "txt":
					return "file_txt_ico_d32";
					break;
				default:
					return "file_chm_ico_d32";
					break;
				}
				if(type=="doc"){
					return "file_word_ico_d32";
				}else if(type=="xls"){
					return "file_excel_ico";
				}else if(type=="jpg"||type=="png"){
					return "file_photo_ico_d32";
				}else if(type=="pdf"){
					return ".file_pdf_ico_d32";
				}
			}
	};
var string={
		getString:function(string){
			if(string==undefined){
				return string=" ";
			}else{
				return string;
			}
		},
		dateFormat:function(date,fmt){
		var time=	Date.parse(date);//这里得到的是时间戳，要转换为Date
		var data=new Date(parseInt(time));
		var m=data.getDate()+1;
			var o = { 
				    "M+" : data.getMonth()+1,                 //月份 
				    "d+" : data.getDate(),                    //日 
				    "h+" : data.getHours(),                   //小时 
				    "m+" : data.getMinutes(),                 //分 
				    "s+" : data.getSeconds(),                 //秒 
				    "q+" : Math.floor((data.getMonth()+3)/3), //季度 
				    "S"  : data.getMilliseconds()             //毫秒 
				  }; 
				  if(/(y+)/.test(fmt)) 
				    fmt=fmt.replace(RegExp.$1, (data.getFullYear()+"").substr(4 - RegExp.$1.length)); 
				  for(var k in o) 
				    if(new RegExp("("+ k +")").test(fmt)) 
				  fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length))); 
				  return fmt; 
		},
		getUrlParam:function(name){
			var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg);  //匹配目标参数
            if (r != null) return unescape(r[2]); return null; //返回参数值
		},
		formatNum:function(s, n) {  
		    n = n > 0 && n <= 20 ? n : 2;  
		    s = parseFloat((s + "").replace(/[^\d\.-]/g, "")).toFixed(n) + "";  
		    var l = s.split(".")[0].split("").reverse(), r = s.split(".")[1];  
		    t = "";  
		    for (i = 0; i < l.length; i++) {  
		        t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? "," : "");  
		    }  
		    var num=t.split("").reverse().join("") + "." + r;
		    return num; 
		}
		
};
var is_commons = 0;
var toast = {
	/**
	 * 成功提示
	 * 
	 * @param text
	 *            内容
	 * @param title
	 *            标题
	 */
	success : function(text, title) {
		toastr.options = {
			"closeButton" : true,
			"debug" : false,
			"positionClass" : "toast-top-center",
			"onclick" : null,
			"showDuration" : "1000",
			"hideDuration" : "1000",
			"timeOut" : "2000",
			"extendedTimeOut" : "1000",
			"showEasing" : "swing",
			"hideEasing" : "linear",
			"showMethod" : "fadeIn",
			"hideMethod" : "fadeOut"
		};
		toastr.success(text, title);
	},
	/**
	 * 失败提示
	 * 
	 * @param text
	 *            内容
	 * @param title
	 *            标题
	 */
	error : function(text, title) {
		toastr.options = {
			"closeButton" : true,
			"debug" : false,
			"positionClass" : "toast-top-center",
			"onclick" : null,
			"showDuration" : "1000",
			"hideDuration" : "1000",
			"timeOut" : "2000",
			"extendedTimeOut" : "1000",
			"showEasing" : "swing",
			"hideEasing" : "linear",
			"showMethod" : "fadeIn",
			"hideMethod" : "fadeOut"
		};
		toastr.error(text, title);
	},
	/**
	 * 信息提示
	 * 
	 * @param text
	 *            内容
	 * @param title
	 *            标题
	 */
	info : function(text, title) {
		toastr.options = {
			"closeButton" : false,
			"debug" : false,
			"positionClass" : "toast-top-center",
			"onclick" : null,
			"showDuration" : "1000",
			"hideDuration" : "1000",
			"timeOut" : "3000",
			"extendedTimeOut" : "1000",
			"showEasing" : "swing",
			"hideEasing" : "linear",
			"showMethod" : "fadeIn",
			"hideMethod" : "fadeOut"
		};
		toastr.info(text, title);
	},
	/**
	 * 警告提示
	 * 
	 * @param text
	 *            内容
	 * @param title
	 *            标题
	 */
	warning : function(text, title) {
		toastr.options = {
			"closeButton" : false,
			"debug" : false,
			"positionClass" : "toast-top-center",
			"onclick" : null,
			"showDuration" : "1000",
			"hideDuration" : "1000",
			"timeOut" : "2000",
			"extendedTimeOut" : "1000",
			"showEasing" : "swing",
			"hideEasing" : "linear",
			"showMethod" : "fadeIn",
			"hideMethod" : "fadeOut"
		};
		toastr.warning(text, title);
	}
};

/**
 * 加载条的选项
 */
var opts = {

        lines: 9, // The number of lines to draw

        length: 0, // The length of each line

        width: 10, // The line thickness

        radius: 15, // The radius of the inner circle

        corners: 1, // Corner roundness (0..1)

        rotate: 0, // The rotation offset

        color: '#000', // #rgb or #rrggbb

        speed: 1, // Rounds per second

        trail: 60, // Afterglow percentage

        shadow: false, // Whether to render a shadow

        hwaccel: false, // Whether to use hardware acceleration

        className: 'spinner', // The CSS class to assign to the spinner

        zIndex: 2e9, // The z-index (defaults to 2000000000)

        top: 'auto', // Top position relative to parent in px

        left: 'auto' // Left position relative to parent in px
    };
/*var spinner = new Spinner(opts).spin();//进度条
*/jQuery(function($) {
	var date=new Date();
	for(var i=date.getFullYear();i>=1980;i--){
		$("#nd").append("<option value='"+i+"'>"+i+"</option>"); 
	}
	$(document).ready(function() {
		// enabling stickUp on the '.navbar-wrapper' class
		/*$('.nav_bar').stickUp();*/
//		$("#container").width(1080);
//		$("#main-container").height(getWindowHieght());
		$("#main-container").css("min-height",getWindowHieght());
		//$("#main-container").css("margin-bottom", 50);
		//开启前端验证框架
		 //$("input,select,textarea").not("[type=submit]").jqBootstrapValidation(); 
		 var date=new Date();
		 //alert( date.getFullYear());
		 for(var i=1980;i<2020;i++){
			 
		 }
		// $("#nd").append("<option value='Value'>Text</option>"); 
	});
});

/**
 * 绑定点击事件
 */
$(function() {
	$("#btn-refresh").on("click",function(){
		  window.location.reload();
	});
	$("#del_all_cbx").on("click", function() {
		var $cbxs = $("[name='del_cbx']");
		$cbxs.each(function() {
			if ($(this).is(":checked")) {
				$(this).prop("checked", false);
				$(this).parent().parent().removeClass('fileSelect');
			} else {
				$(this).prop("checked", true);
				$(this).parent().parent().addClass('fileSelect');
				
			}
		});
	});
	$("#btn_del").on("click",function(){
		var nbxhs=new Array();
		$("input[name='del_cbx']:checked").each(function(i,ele){
			nbxhs[i]=$(this).attr("id");
		});
		if(nbxhs.length<=0){
			$("#delModal").modal("hide");
			toast.error("请选择要删除的文件", "温馨提示");
			return false;
		}
		
		$.ajax({
			type : "post",
			url : "/DocMan/webService/show/DocFile/deleteFiles",
			traditional:true,
			data : {fileIds:nbxhs},
			success:function(data){
				$("#delModal").modal("hide");
				refresh();
				toast.success("删除成功，后台正在删除文件，请稍后刷新", "温馨提示");
			},
			error:function(data){
				
			}
		});
	});
	$("input[name='del_cbx']").on("click",function(){
		if($(this).is(':checked')){
			$(this).parent().parent().addClass('fileSelect');
		}else{
			$(this).parent().parent().removeClass('fileSelect');
		}
	});
	
	$("#del_confirm_btn").on("click",function(){
		$("#delModal").modal({backdrop: 'static', keyboard: false,show:true});
	});
	/**
	 * 文件夹的重命名 start
	 */
	$(".directory_list").on("click",".btn-directory-attr",function(){
		  var directoryId=$(this).attr('id');
		  $("#btn-directory-save").val(directoryId);
		  $.ajax({
			 type:"post",
			 url:"/DocMan/webService/show/DocDirectory/getDirectory",
			 data:{directoryId:directoryId},
			 success:function(data){
				 $("#directoryLocation").html(data["path"]);
				 $("#directoryCreate").html(data["directory"].humanName+"&nbsp;"+string.dateFormat(data["directory"].createTime, "yyyy-MM-dd hh:mm"));
				 $("#directorySize").html(data["directory"].large+"MB");
				 $("#directoryContain").html(data["directory"].fileCount+"个文件，"+data["directory"].directoryCount+"个文件夹");
				 $("#directoryNameAttr").val(data["directory"].reName);
				 $("#directoryAttrModal").modal({backdrop: 'static', keyboard: false,show:true});
				 $("#dirRangeAttr").val(data["directory"].displayRange);
				 if(data["directory"].displayRange=="2"){
					 $("#inputHumanAttr").show();
					 $("#humanNamesAttr").find(".human_tag").remove();
					 $(data["tchumans"]).each(function(i,e){
						 var humanTag="<div id=\""+e.humanid+"\" class=\"human_tag\">"+
							"<span style=\"width:60%;\">"+e.humanname+"</span>"+
							"<div class=\"human_tag_remove\">"+
								"<span class=\"glyphicon glyphicon-remove\" style=\"font-size:2px;color:#fff;\"></span>"+
							"</div>"+
						"</div>";
						  $("#humanNamesAttr").append(humanTag);
					 });
				 }else{
					 $("#inputHumanAttr").hide();
					 $("#humanNamesAttr").find(".human_tag").remove();
				 }
			 },
			 error:function(data){
				 
			 }
		  });
	  });
	  $("#btn-directory-save").on("click",function(){
		 var directoryName=$("#directoryNameAttr").val().trim();
		 var directoryId=$(this).val();
		 var humanIds=new Array();
		 var displayRange=$("#dirRangeAttr").children('option:selected').val(); 
		 if(displayRange==2){
			 $($("#humanNamesAttr").find(".human_tag")).each(function(i,e){
				 humanIds[i]=$(this).attr('id');
			 });
		 }
		 $.ajax({
			type:"post",
			url:"/DocMan/webService/show/DocDirectory/saveOrUpdate",
			data:{reName:directoryName,id:directoryId,displayRange:displayRange,humanIds:humanIds},
			traditional:true,
			success:function(data){
				if(data["success"]){
					refresh();
				}else{
					toast.error(data["message"], "温馨提示");
				}
			},
			error:function(data){
				toast.error("请求错误", "温馨提示");
			}
		 });
	  });
	  /**
		 * 文件夹的重命名 end
		 */
	  $(".btn-delDir-modal").on("click",function(){
		  var dirId=$(this).attr('id');
		  $("#btn_deleteDir").val(dirId);
		  $("#delDirModal").modal({backdrop: 'static', keyboard: false,show:true});
		  /*$.ajax({
			 type:"post" ,
			 url:"/DocMan/webService/show/DocDirectory/delete",
			 data:{directoryId:dirId},
			 success:function(data){
				 refresh();
			 },
			 error:function(data){
				 toast.error("删除出现错误或没有权限", "温馨提示");
			 }
		  });*/
	  });
	  $("#btn_deleteDir").on("click",function(){
		  var dirId=$(this).val();
		  $.ajax({
				 type:"post" ,
				 url:"/DocMan/webService/show/DocDirectory/delete",
				 data:{directoryId:dirId},
				 success:function(data){
					 if(data["success"]){
						 refresh();
					 }else{
						 toast.error(data["message"], "温馨提示");
						 $("#delDirModal").modal('hide');
					 }
				 },
				 error:function(data){
					 toast.error("删除出现错误或没有权限", "温馨提示");
				 }
		   });
	  });
	  $("#btn-add-human").on("click",function(){
		  var humanName=$("#humanName").val().trim();
		  $.ajax({
			  type:"post",
			  url:"/DocMan/webService/show/tchumanService/getHumanByName",
			  data:{username:humanName},
			  success:function(data){
				  var human=data["human"];
				  console.info(data);
				  toast.success("添加成功", "温馨提示");
				  var humanTag="<div id=\""+human.humanid+"\" class=\"human_tag\">"+
								"<span style=\"width:60%;\">"+human.humanname+"</span>"+
								"<div class=\"human_tag_remove\">"+
									"<span class=\"glyphicon glyphicon-remove\" style=\"font-size:2px;color:#fff;\"></span>"+
								"</div>"+
							"</div>";
				  $("#humanNames").append(humanTag);
			  },
			  error:function(data){
				  toast.error("没有这个人员", "温馨提示");
			  }
		  });
	  });
	  $("#btn-add-humanAttr").on("click",function(){
		  var humanName=$("#humanNameAttr").val().trim();
		  $.ajax({
			  type:"post",
			  url:"/DocMan/webService/show/tchumanService/getHumanByName",
			  data:{username:humanName},
			  success:function(data){
				  var human=data["human"];
				  console.info(data);
				  toast.success("添加成功", "温馨提示");
				  var humanTag="<div id=\""+human.humanid+"\" class=\"human_tag\">"+
								"<span style=\"width:60%;\">"+human.humanname+"</span>"+
								"<div class=\"human_tag_remove\">"+
									"<span class=\"glyphicon glyphicon-remove\" style=\"font-size:2px;color:#fff;\"></span>"+
								"</div>"+
							"</div>";
				  $("#humanNamesAttr").append(humanTag);
			  },
			  error:function(data){
				  toast.error("没有这个人员", "温馨提示");
			  }
		  });
	  });
	  $("#humanNamesAttr").on("click",".human_tag_remove",function(){
		  $(this).parent().remove();
	  });
	  $("#dirRangeAttr").change(function(){
			 var rangeId=$(this).children('option:selected').val(); 
			 if(rangeId==2){
				/*  $("#inputHuman").css('display','block'); */
				 $("#inputHumanAttr").show();
			 }else{
				/*  $("#inputHuman").css('display','none'); */
				$("#inputHumanAttr").hide();
				 $("#humanNamesAttr").find(".human_tag").remove();
			 }
		  });
	  
	  $("#humanNames").on("click",".human_tag_remove",function(){
		  $(this).parent().remove();
	  });
	  $("#dirRange").change(function(){
			 var rangeId=$(this).children('option:selected').val(); 
			 if(rangeId==2){
				/*  $("#inputHuman").css('display','block'); */
				 $("#inputHuman").show();
			 }else{
				/*  $("#inputHuman").css('display','none'); */
				$("#inputHuman").hide();
				 $("#humanNames").find(".human_tag").remove();
			 }
		  });
	  $(".file_list").on("click",".file_record",function(){
			 var fileId=$(this).attr("id");
			 $.ajax({
				 type:"post",
				 url:"/DocMan/webService/show/docRecord/getRecords",
				 data:{fileId:fileId},
				 success:function(data){
					 $(".record_list").find(".record").remove();
					 $(data["records"]).each(function(i,e){
						var record="<tr class=\"record\">"+
										"<td>"+e.humanName+"</td>"+
										"<td>"+string.dateFormat(e.createTime, "yyyy-MM-dd hh:mm:ss")+"</td>"+
										"<td>"+e.type+"</td>"+
									"</tr>";
						$(".record_list").append(record);
					 });
					 $(".record_list").css("height","150px");
					 $(".record_list").css('max-height',"150px");
					 $("#fileNameAttr").val(data["file"].fileName);
					 $("#fileSize").html(data["file"].large+"M");
					 $("#fileCreate").html(string.dateFormat(data["file"].createTime,"yyyy-MM-dd hh:mm:ss"));
					 $("#fileRecordModal").modal({backdrop: 'static', keyboard: false,show:true});
				 },
				 error:function(data){
					 toast.error("请求错误", "温馨提示");
				 }
			 });
		  });
	  	$("#btn_index_dir").on("click",function(){
	  		var dirId=string.getUrlParam("directoryId");
	  		$.ajax({
				 type:"post",
				 url:"/DocMan/webService/show/DocDirectory/getUnIndexFile",
				 data:{directoryId:dirId},
				 success:function(data){
					 var str="";
					 if(data["success"]){
						 str="当前文件夹下及子目录下共有 "+data["unIndexFileCount"] +"个文件没有归档";
					 }else{
						 str=data["message"];
					 }
					 $("#dirIndexFileCount").html(str);
					 $(".progress").hide();
					 $(this).attr("disabled",false);
					 $("#indexNd").find("option").remove();
					 var date=new Date();
					 for(var i=date.getFullYear();i>=1980;i--){
							$("#indexNd").append("<option value='"+i+"'>"+i+"</option>"); 
						}
					 $("#indexDirModal").modal({backdrop: 'static', keyboard: false,show:true});
				 },
				 error:function(data){
					 toast.error("请求错误", "温馨提示");
				 }
			 });
	  	});
	  	$("#btn_start_indexDir").on("click",function(){
	  		var dirId=string.getUrlParam("directoryId");
	  		$(this).attr("disabled",true);
	  		var nd=$("#indexNd").val();
	  		console.info(nd);
	  		$.ajax({
	  			type:"post",
	  			url:"/DocMan/webService/show/DocDirectory/indexDirectory",
	  			data:{directoryId:dirId,indexNd:nd},
				success:function(data){
				 },
				 error:function(data){
					 toast.error("请求错误", "温馨提示");
				 }
	  		});
	  		$("#dirIndexFileCount").html("后台正在加载数据");
	  		setTimeout(function(){
	  			$(".progress").show();
				//定时更新文件夹内文件的索引进度
				var wait=setInterval(function(){
					$.ajax({
						 type:"post",
						 url:"/DocMan/webService/show/DocDirectory/getUnIndexFile",
						 data:{directoryId:dirId},
						 success:function(data){
							 var str="";
							 if(data["success"]){
								 var parentWidth=$("#progress-bar").parent().css("width").substr(0,3);
								 str="当前有 "+data["unIndexFileCount"] +"个文件没有归档，有 "+data["dirCount"]+"个文件夹没有建立";
								 var percentage=data["indexFile"]/(data["indexFile"]+data["unIndexFileCount"]);
								 percentage=string.formatNum(percentage, 0)*parentWidth;
								 $("#dirIndexFileCount").html(str);
								 if(percentage>0){
//									 $("#progress-bar").css("width",percentage);
									 $("#progress-bar").width(percentage);
								 }
								 if(data["unIndexFileCount"]==0){
									 clearInterval(wait);
									 $("#dirIndexFileCount").html("文件索引建立完成");
									 setTimeout(function(){
										 refresh();
									 }, 1000);
								 }
							 }else{
								 str=data["message"];
								 clearInterval(wait);
							 }
//							 $("#dirIndexFileCount").html(str);
						 },
						 error:function(data){
							 toast.error("请求错误", "温馨提示");
						 }
					 });
				}, 1000);
	  		}, 1500);
	  	});
	  	$(".file_list").on("click",".file_collect",function(){
	  		var type=$(this).attr("type");
	  		window.localStorage.setItem("collectFileId", $(this).attr("id"));
	  		window.localStorage.setItem("collectFileType",type);
	  		$("#collectFileModal").modal({backdrop: 'static', keyboard: false,show:true});
	  	});
	 	$(".myDir_lists").on("click",".myFirstDir",function(){
	  		var dirId=parseInt($(this).attr('id'));
	  		var uls=$(this).closest("li").find("ul");
	  		var li=$(this).closest("li");
	  		var a=this;
	  		if(uls.length==0){
	  			$.ajax({
		  			type:"post",
		  			url:"/DocMan/webService/show/DocDirectory/personalDirectories",
		  			data:{directoryId:dirId},
		  			success:function(data){
		  				if(data["success"]){
		  					console.info(data);
		  					console.info(dirId);
		  					var pre="<ul class=\"disk-copy-ul unstyled\">";
		  					$(data["personalDirectories"]).each(function(i,ele){
		  						pre=pre+"<li>"+
								      	  	"<a href=\"javascript:void(0);\" class=\"myFirstDir\" id=\""+ele.id+"\">"+
								      	       "<i class=\"diskpic-copy-right mgtDiskListArrows\"></i>"+
								      	  "</a>"+                                          
								      	  "<span class=\"ch mgtActive\"><i class=\"diskpic-smallbox\"></i><span class=\"me-margin-left5\">"+ele.reName+"</span></span>"+
								     "</li>";
		  					})
		  					if(data["personalDirectories"].length==0){
		  						pre=pre+"<li>没有文件夹了</li>"
		  					}
		  					pre=pre+"</ul>";
		  					showClass(a,'diskpic-copy-bottom','diskpic-copy-right');
//		  					var lis=$(this).parent("li");
//		  					console.info(lis.length);
		  					$(li).append(pre);
//		  					$("#"+dirId).parent("li").append(pre);
		  				}else{
		  					toast.error("获取失败", "温馨提示");
		  				}
		  			},
		  			error:function(data){
		  				
		  			}
		  		});
	  		}else{
	  			var ulFisrt=$(this).closest("li").find("ul")[0];
	  			showElement(ulFisrt);
	  			showClass(a,'diskpic-copy-bottom','diskpic-copy-right');
	  		}
	  	});
	 	$(".myDir_lists").on("click",".mgtActive",function(){
	 		$(".myDir_lists").find(".mgtActive").removeClass("active");
	 		$(this).addClass("active");
	 	})
	 	$("#btn_collect").on("click",function(){
	 		var directoryId=$(".mgtActive.active").prev().attr("id");
	 		var collectFileId=window.localStorage.getItem("collectFileId");
	 		var collectFileType=window.localStorage.getItem("collectFileType");
	 		console.info(directoryId);
	 		console.info(collectFileId);
	 		console.info(collectFileType);
	 		$.ajax({
	 			type:"post",
	 			url:"/DocMan/webService/show/DocFile/collectFile",
	 			data:{collectFileId:collectFileId,directoryId:directoryId,collectFileType:collectFileType},
	 			success:function(data){
	 				if(data["success"]){
	 					toast.success("文件收藏成功", "温馨提示");
	 					$("#collectFileModal").modal("hide");
	 				}else{
	 					toast.error("文件复制发生错误", "温馨提示");
	 				}
	 			},
	 			error:function(data){
	 				toast.error("网络或请求错误", "温馨提示");
	 			}
	 		})
	 	});
});


function showElement(ele){
	/*if($(ele).css("display")=="none"){
		$(ele).css("display","block");
	}else{
		$(ele).css("display","none;")
	}*/
	$(ele).toggle();
}

function showClass(ele,showClass,removeClass){
	if($(ele).find("i").hasClass(removeClass)){
		$(ele).find("i").removeClass(removeClass);
		$(ele).find("i").addClass(showClass);
	}else{
		$(ele).find("i").removeClass(showClass);
		$(ele).find("i").addClass(removeClass);
	}
}
function getObjectURL(file) {
	var url = null ; 
	if (window.createObjectURL!=undefined) { // basic
		url = window.createObjectURL(file) ;
	} else if (window.URL!=undefined) { // mozilla(firefox)
		url = window.URL.createObjectURL(file) ;
	} else if (window.webkitURL!=undefined) { // webkit or chrome
		url = window.webkitURL.createObjectURL(file) ;
	}
	return url ;
}
/**
 * 显示进度条
 */
function showLoader(){
	var target=$("#loader");
	var show = target.css('display');
	//$('#test').css('display',show =='block'?'none':show);
	if(show=='none'){
		target.css('display','block');
	}
	target.append(spinner.el);
}

function hideLoader(){
	var target=$("#loader");
	target.hide();
}
function back(){
	window.history.go(-1);
}

function isNumber(number){
	return isNaN(parseInt(number));
}

function clearInput(id) {
	if (id == 0) {
		$(":input").each(function() {
			$(this).val("");
		});
	} else {
		$(id).each(function() {
			$(this).val("");
		});
	}
	$("#addXmModal select").each(function(){
		$(this).val(0);
	});
};
function mySubmit(flag){  
    return flag;  
} ;
function refresh(){
	  window.location.reload();
}

function getWindowHieght(){
	var height=$(window).height();
	return height;
}

function getWindowWidth(){
	var width=$(window).width();
	return width;
}

function getSessionValue(key){
	var editable=window.sessionStorage.getItem("edit");
	if(editable==null||typeof(editable)==undefined||editable==""){
		$.ajax({
			type:"post",
			url:"/dangan/webService/show/tcrole/getSessionValue",
			data:{key:key},
			success:function(data){
				console.info(data["data"]);
				if(typeof(data)!=undefined&&data!=null&&data!=""){
					window.sessionStorage.setItem("edit", data["data"]);
				}
			},
			error:function(data){}
		});
	}
}
function lwdw(){
	console.info($("#bj").attr("checked"))
	if($("#bj").attr("checked"))
	{
		$("#lwdwb").val("1");
		console.info($("#lwdwb").val())
	}
	if($("#sj").attr("checked"))
	{
		$("#lwdws").val("1");
		console.info($("#lwdws").val())
	}
	if($("#shij").attr("checked"))
	{
		$("#lwdwshi").val("1");
		console.info($("#lwdwshi").val())
	}	
}

